package com.bawei.library_common.utils

import com.bawei.library_base.utils.GsonUtil


/**
 * @author hahajing 企鹅：444511958
 * @createDate 2022/8/11 8:40
 * @description
 *
 * @updateUser hahajing
 * @updateDate 2022/8/11 8:40
 * @updateRemark
 *
 * @version 1.0.0
 */
object UserUtils {
    /**
     * 判断用户是否登录
     */
    fun isLogin():Boolean{
        val user = DataStoreUtils.getData("token","")
        if(!user.isBlank()){
            return true
        }
        return false
    }

    /**
     * 获取当前登录用户
     */
    fun getCurrentUser():UserEntity?{
        val user = DataStoreUtils.getData("user","")
        if (!user.isBlank()){
            val currentUser= GsonUtil.fromJson<UserEntity>(user,UserEntity::class.java)
            return currentUser
        }
        return null
    }

    /**
     * 获取登录用户Json数据
     */
    fun getCurrentUserJson():String{
        val user = DataStoreUtils.getData("user","")
        if (!user.isBlank()){
            return user
        }
        return ""
    }
}